//
// Created on 2025/7/21.
//
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
// please include "napi/native_api.h".

#include "Asset.h"
#include "models/utils.h"
#include <fcntl.h>

Asset::Asset() 
{
    m_id = GenerateUniqueId("asset");
}

Asset::~Asset() = default;

Asset::Asset(const std::string& path, AssetType type) :
    m_path(path),
    m_type(type)
{
    m_id = GenerateUniqueId("asset");
}

void Asset::SetOriginalDuration(uint64_t originalDuration)
{
    m_originalDuration = originalDuration;
}

const std::string Asset::GetId()
{
    return m_id;
}

const std::string Asset::GetPath()
{
    return m_path;
}

const uint64_t Asset::GetOriginalDuration()
{
    return m_originalDuration;
}

const int32_t Asset::GetSourceFd()
{   
    LOGD("Asset::GetSourceFd.");
    if (m_path == "") {
        LOGE("Asset::GetSourceFd path is empty.");
        return -1;
    }
    
    int32_t fd = open(m_path.c_str(), O_RDONLY);
    return fd;
}



